import { Ref } from 'vue';

// type/index.ts
export interface SelectOption {
  value: any;
  label?: string;
  name?: string;
}

export interface Column {
  prop: string; //
  label: string;
  visible: boolean;
  fixed?: 'left' | 'right';
  width?: number;
  component?: string;
  options?: SelectOption[]; // 使用具体类型替代 any[]
}

export interface ValidationRule {
  required?: boolean;
  pattern?: RegExp;
  message?: string;
  validator?: (value: any) => boolean;
}

export interface Cell {
  [key: string]: any; // 允许动态属性
  isCheckbox?: boolean;
}

// 定义类型，增强代码可读性和类型安全
export interface CellPosition {
  row: number;
  col: number;
}

export interface DragStartInfo extends CellPosition {
  x: number;
  y: number;
}

export interface DragRange {
  minRow: number;
  maxRow: number;
  minCol: number;
  maxCol: number;
}

export interface DragPreviewInfo {
  visible: boolean;
  x: number;
  y: number;
  width: number;
  height: number;
}

// 添加行编辑状态类型
export interface EditState {
  rowIndex: number | null;
  rowData: Record<string, any>;
  originalData: Record<string, any> | null;
}

// 添加验证错误类型
export interface ValidationError {
  [rowIndex: number]: {
    [field: string]: string;
  };
}

// type/index.ts
export interface ValidationRule {
  required?: boolean;
  pattern?: RegExp;
  message?: string;
  validator?: (value: any) => boolean;
}

export interface ValidationConfig {
  [prop: string]: ValidationRule[];
}

// 提示框状态接口定义
export interface TooltipState {
  visible: boolean;
  x: number;
  y: number;
  content: string;
}
